/*
##############################################################################################
#	Compress URL (http://code.google.com/p/compressurl)
#	Author : Abhishek Verma (vermaabhishekp@gmail.com)
#	
#	This file is part of Compress URL.
#	
#	Compress URL is free software: you can redistribute it and/or modify
#	it under the terms of the GNU General Public License as published by
#	the Free Software Foundation, either version 3 of the License, or
#	(at your option) any later version.
#	
#	Compress URL is distributed in the hope that it will be useful,
#	but WITHOUT ANY WARRANTY; without even the implied warranty of
#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#	GNU General Public License for more details.
#	
#	You should have received a copy of the GNU General Public License
#	along with Compress URL.  If not, see <http://www.gnu.org/licenses/>.
#	
#	add.js.php : 
#
#		Javascript API : A simple ajax request
##############################################################################################
*/

// Sends GET var queryString through an AJAX request
function API_compress_url(queryString, callBack) {
	var xmlHttpReq = false;
	var self = this;
	
	// The URL where to POST
	var strURL = "../api.php";
	
	if (window.XMLHttpRequest) {
		// Mozilla/Safari
		self.xmlHttpReq = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		// IE
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	self.xmlHttpReq.open('GET', strURL+"?"+queryString, true);
	
	// If got reply
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			// Refresh div check on getting reply
			eval(callBack+"('"+self.xmlHttpReq.responseText+"')");
		}
	}
	
	self.xmlHttpReq.send(null);
}